<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="装车查询" left-arrow @click-left="$router.go(-1)"></van-nav-bar>

    <div class="billContent">  出车登记单号 ：{{bill}}</div>

		<div class="tableContent">
      <data-table
			:table-data="tableData"
			:columns="columns"
			height="calc(100vh - 200px)"
		/>
    </div>

		<div class="footerBtn">
			<van-button type="default" @click="$router.go(-1)">返回</van-button>
			<van-button type="info" :disabled="isdisabled" @click="overZhuangCheBtn()">整单结单</van-button>
		</div>









	</div>
</template>

<script>
import DataTable from '@/components/DataTable.vue'

export default {
  name: 'zhuangcheSon',
  data() {
    return {
			isdisabled:false,
			bill:'',
			tableData:[
				{
					ck_storeid:'',
					storename:'',
					mb_rqh:'',
					psbill:'',
					spcount:'',
					totqty:'',
					pack:'',
					qty:'',
				}
			],
			columns: [
				{ prop: 'ck_storeid', label: '门店号', width: '100' },
				{ prop: 'storename', label: '门店名称', width: '150' },
				{ prop: 'mb_rqh', label: '容器号', width: '120' },
				{ prop: 'psbill', label: '配送单号', width: '120' },
				{ prop: 'spcount', label: '商品种数', width: '100' },
				{ prop: 'totqty', label: '托盘数量', width: '100' },
				{ prop: 'pack', label: '件数', width: '80' },
				{ prop: 'qty', label: '散数', width: '80' }
			],
		};
  },
	computed: {
	   ryuser: function(){
	     return this.GWO(true).gUSER;
	   }
	},
  methods: {
		zhuangCheSearchBtn(){
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_fenbo',
				'i':this.FNULLE([
				'opmode','ZC_jsqry_bill',
				'kqid', _self.ryuser.kqid,
				'czyid',_self.ryuser.operatorid,
				'bill',_self.bill,
				])
				},'查询出车登记单号',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					_self.tableData = rtn_json_obj
					console.log("查询出车登记单号")
					console.log(rtn_json_obj)
					_self.tableData = rtn_json_obj
					if(_self.tableData.length > 0){
						// _self.isSkuVisible = true
					}else{
						_self.$toast.fail('暂无出车登记单')
					}
				}
			});
		},
		overZhuangCheBtn(){
			this.$dialog.confirm({
			  title: '提示',
			  message: '是否结束装车?',
				confirmButtonColor:'#4C71F6'
			}).then(() => {
				this._getOverZhuangChe()
			    // on confirm
			}).catch(() => {
			    // on cancel
			});
		},
		_getOverZhuangChe(){
			console.log("传值")
			console.log(this.editForm)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_fenbo',
					'i':this.FNULLE([
					'opmode','ZC_jszc_bill',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'bill',this.bill,
				])
				}, '结束装车',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					// _self.skuData = rtn_json_obj
					console.log("得到结束装车")
					console.log(rtn_json_obj[0])
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$toast(rtn_json_obj[0].ret_mess)
					}else{
						_self.$toast('装车成功')
					}
				}
			});
		},
  },
  mounted() {
		this.bill = this.$route.query.bill
		this.zhuangCheSearchBtn()
  },
	components: {
		DataTable
	},
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}
  .billContent{
    width: 100%;
    height: 30px;
    color: #333;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding-left: 10px;
    font-weight: bold;
  }

  .tableContent{
    width: 96%;
    margin: 20px auto;
  }

</style>
